package com.bigshen.demo.xml;

import com.bigshen.demo.project.entity.Person;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class XmlApplicationTest {

    /**
     * xml方式的IOC容器启动方式一般有两种：
     * 1. web项目在web.xml中指定DispatcherServlet，配置IOC容器初始化
     * 2. 直接使用ClassPathXmlApplicationContext方式获取IOC容器
     */
    @Test
    public void test() {

        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("application.xml");

        Person person = (Person) applicationContext.getBean("person");
        System.out.println(person);

        Person person2 = applicationContext.getBean(Person.class);
        System.out.println(person2);

        System.out.println(person == person2);

    }

}
